import { DataType } from "./type";
import type { IDeserializable } from "~/models/serialize/IDeserializable";
import { Deserializer } from "~/models/serialize/Deserializer";
import { Dzer } from "~/models/serialize";

// 定义: 接口类型 (和类型)：
// 不是一种具体的类型，而是类型的类型。在这里定义结构和生成器

export class PremiumType
  extends DataType
  implements IDeserializable
{
  className: string = 'PremiumType'

  constructor(
    public name: string,
    public _default: any,
    public jsType: string,
  ) {
    super()
  }

  get default(): any {
    return this._default
  }

  // 基本类型是类型系统的最小元。只能接受完全一致的类型
  receiveType(t: DataType): boolean {
    return this.name === t.name;
  }

  receiveValue(t: any): boolean {
    return Object.prototype.toString.call(t) === this.jsType
  }
}